home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / shellscr / src / clr.asm < prev    next >
Assembly Source File  |  1999-11-30  |  811b  |  32 lines

  1. ; mem := clr(mem, sze)
  2. ; clears sze bytes of memory starting at mem, returns mem
  3.  
  4. ; mem := memset(mem, chr, sze)
  5. ; puts char chr into sze bytes of memory starting at mem. returns mem
  6.  
  7. ; PROC memset(mem:PTR TO CHAR, chr, sze)
  8. ;   DEF end; end := mem + sze
  9. ;   WHILE mem < end DO mem[]++ := chr
  10. ; ENDPROC mem - sze
  11.  
  12. ; PROC clr(mem, sze) IS memset(mem, 0, sze)
  13.  
  14.     xdef    clr__ii
  15. clr__ii    move.l    4(sp),a1    ; get sze
  16.     moveq    #0,d0        ; chr = 0
  17.     bsr.s    _bla        ; jump into memset with 4 more bytes on stack:
  18.     rts            ; mem=8(sp) -> mem=12(sp). sze/chr already set
  19.  
  20.     xdef    memset__iii
  21. memset__iii
  22.     move.l    8(sp),d0    ; get chr
  23.     move.l    4(sp),a1    ; get sze
  24. _bla    move.l    12(sp),a0    ; get mem
  25.     adda.l    a0,a1
  26. .loop    cmp.l    a0,a1
  27.     bls.s    .exit        ; exit when a0 >= end
  28.     move.b    d0,(a0)+    ; a0[]++:=d0
  29.     bra.s    .loop        ; repeat
  30. .exit    move.l    12(sp),d0
  31.     rts
  32.